﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Global.Class.Library;

namespace DataTransferObject
{

    public class InMarketMaster : NotifyPropertyChangeObject
    {

        private int inMarketID;

        private string reference;
        private string description;
        private string other;

        private int orderOrReturnID;
        private int customerID;
        private string customerValue;
        private int distributorID;
        private int salesmenID;
        private int promotionCampaignID;
        private int returnCategoryID;
        private int refuseCategoryID;
        private int importBatchID;

        private DateTime inMarketDate;
        private DateTime entryDate;


        public InMarketMaster()
        {
            GlobalDefaultValue.Apply(this);

            this.InMarketDate = DateTime.Today;
            this.EntryDate = DateTime.Today;
        }

        #region Properties


        [DefaultValue(-1)]
        public int InMarketID
        {
            get { return this.inMarketID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.inMarketID, o => o.InMarketID, value); }
        }


        [DefaultValue("")]
        public string Reference
        {
            get { return this.reference; }
            set { ApplyPropertyChange<InMarketMaster, string>(ref this.reference, o => o.Reference, value); }
        }


        [DefaultValue("")]
        public string Description
        {
            get { return this.description; }
            set { ApplyPropertyChange<InMarketMaster, string>(ref this.description, o => o.Description, value); }
        }


        [DefaultValue("")]
        public string Other
        {
            get { return this.other; }
            set { ApplyPropertyChange<InMarketMaster, string>(ref this.other, o => o.Other, value); }
        }

        
        

        //[DefaultValue(0)]
        public int OrderOrReturnID
        {
            get { return this.orderOrReturnID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.orderOrReturnID, o => o.OrderOrReturnID, value); }
        }

        [DefaultValue(0)]
        public int CustomerID
        {
            get { return this.customerID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.customerID, o => o.CustomerID, value); }
        }

        [DefaultValue("")]
        public string CustomerValue
        {
            get { return this.customerValue; }
            set { ApplyPropertyChange<InMarketMaster, string>(ref this.customerValue, o => o.CustomerValue, value); }
        }

        [DefaultValue(0)]
        public int DistributorID
        {
            get { return this.distributorID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.distributorID, o => o.DistributorID, value); }
        }

        [DefaultValue(0)]
        public int SalesmenID
        {
            get { return this.salesmenID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.salesmenID, o => o.SalesmenID, value); }
        }

        [DefaultValue(0)]
        public int PromotionCampaignID
        {
            get { return this.promotionCampaignID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.promotionCampaignID, o => o.PromotionCampaignID, value); }
        }

        [DefaultValue(0)]
        public int ReturnCategoryID
        {
            get { return this.returnCategoryID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.returnCategoryID, o => o.ReturnCategoryID, value); }
        }

        [DefaultValue(0)]
        public int RefuseCategoryID
        {
            get { return this.refuseCategoryID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.refuseCategoryID, o => o.RefuseCategoryID, value); }
        }

        [DefaultValue(-1)]
        public int ImportBatchID
        {
            get { return this.importBatchID; }
            set { ApplyPropertyChange<InMarketMaster, int>(ref this.importBatchID, o => o.ImportBatchID, value); }
        }


        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime InMarketDate
        {
            get { return this.inMarketDate; }
            set { ApplyPropertyChange<InMarketMaster, DateTime>(ref this.inMarketDate, o => o.InMarketDate, value); }
        }

        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime EntryDate
        {
            get { return this.entryDate; }
            set { ApplyPropertyChange<InMarketMaster, DateTime>(ref this.entryDate, o => o.EntryDate, value); }
        }



        
        #endregion

        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("Reference", "Reference cannot be blank.", delegate { return this.Reference.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("InMarketDate", "Please input date.", delegate { return this.InMarketDate != null; }));
            validationRules.Add(new SimpleValidationRule("OrderOrReturnID", "Command type cannot be empty.", delegate { return this.OrderOrReturnID > 0; }));
            validationRules.Add(new SimpleValidationRule("CustomerID", "Customer cannot be empty.", delegate { return this.CustomerID > 0; }));
            validationRules.Add(new SimpleValidationRule("SalesmenID", "Salesmen cannot be empty.", delegate { return this.SalesmenID > 0; }));
            validationRules.Add(new SimpleValidationRule("DistributorID", "Distributor cannot be empty.", delegate { return this.DistributorID > 0; }));
            validationRules.Add(new SimpleValidationRule("ImportBatchID", "Import batch cannot be empty.", delegate { return this.ImportBatchID != 0; }));
            
            return validationRules;
        }
    }
}
